package com.shuai.controller;


import com.shuai.model.vo.ProjectVO;
import com.shuai.model.vo.UserVO;
import com.shuai.service.UserService;
import com.shuai.utils.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping(value = "/user")
@Tag(name = "用户管理")
public class UserController {

    @Resource
    private UserService userService;

    /**
     * content-type application/json
     * param:account  Y
     * pwd      Y
     *
     * @param vo
     * @return
     */
    @PostMapping(value = "/userLogin")
    @Operation(summary = "用户登录")
    public R userLogin(@RequestBody UserVO vo) {
        return this.userService.userLoin(vo);
    }

    @PostMapping(value = "/userList")
    @Operation(summary = "分页查询")
    public R userList(@RequestBody Map<String, Object> params) {
        return this.userService.userList(params);
    }

    @PostMapping(value = "/searchUser")
    @Operation(summary = "条件分页查询")
    public R searchUser(@RequestBody Map<String, Object> params) {
        return this.userService.searchUser(params);
    }

    @PostMapping(value = "/addUser")
    @Operation(summary = "添加用户")
    public R addUser(@RequestBody UserVO vo) {
        return this.userService.addUser(vo);
    }

    @PostMapping(value = "/userInfo")
    @Operation(summary = "根据id查询用户,进行数据回显")
    public R userInfo(@RequestBody UserVO vo) {
        return this.userService.userInfo(vo);
    }

    @PostMapping(value = "/updateUser")
    @Operation(summary = "修改用户")

    public R updateUser(@RequestBody UserVO vo) {
        return this.userService.updateUser(vo);
    }

    @PostMapping(value = "/deleteUser")
    @Operation(summary = "根据id删除用户")
    public R deleteUser(@RequestBody UserVO vo) {
        return this.userService.delUser(vo);
    }

    /**
     * 选择项目负责人
     *
     * @return
     */
    @PostMapping(value = "/userListOfManager")
    @Operation(summary = "查询项目负责人")
    public R userListOfManager() {
        return this.userService.userListOfManager();
    }

    /**
     * params: projectId
     * 查询空闲人
     * 添加项目组成员的操作---当前项目的负责人
     */
    @PostMapping(value = "/userListOfNotWork")
    public R userListOfNotWork(@RequestBody ProjectVO vo) {
        return this.userService.userListOfNotWork(vo);
    }

}